/**
 * Copyright (c) 2007 Novell, Inc.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *      Duane Buss
 *      Joshua Gan
 */

package org.eclipse.higgins.idas.cp.f8;

import java.util.Iterator;
import java.util.Map;

import org.eclipse.higgins.configuration.api.IConfigurableComponent;
import org.eclipse.higgins.idas.api.IContext;
import org.eclipse.higgins.idas.api.IContextFactory;
import org.eclipse.higgins.idas.api.IContextId;
import org.eclipse.higgins.idas.api.IdASException;
import org.eclipse.higgins.idas.api.NotImplementedException;
import org.eclipse.higgins.idas.cp.f8.F8Context;
import org.eclipse.higgins.idas.spi.BasicMetadataSet;

/**
 * A
 * <a href="http://www.eclipse.org/higgins/">Higgins</a>
 *  Context Factory for the <a href="http://developer.facebook.com/">f8</a>
 *  Context Provider. 
 *  
 * @author josh.gan@gmail.com
 */
public class F8ContextFactory extends BasicMetadataSet implements IContextFactory, IConfigurableComponent {

	private String _apiKey;
	private String _apiSecret;
	
    public F8ContextFactory() throws IdASException {
        super();
    }

    
    /*
     *  (non-Javadoc)
     * @see org.eclipse.higgins.idas.api.IContextFactory#getName()
     */
    public String getName() throws IdASException {
        return "F8 Context Provider";
    }
    
    
    /*
     *  (non-Javadoc)
     * @see org.eclipse.higgins.idas.api.IContextFactory#getContexts(java.lang.String)
     */
    public Iterator getContexts(String filter)
      throws IdASException {
        throw new NotImplementedException();
    }

    
    public IContext createContext(IContextId contextID)
      throws IdASException {
        return new F8Context(contextID, _apiKey, _apiSecret);
    }

    
    /*
     *  (non-Javadoc)
     * @see org.eclipse.higgins.idas.api.IContextFactory#getPolicy()
     */
    public String getPolicy() throws IdASException {
        throw new NotImplementedException();
    }

    
    /*
     *  (non-Javadoc)
     * @see org.eclipse.higgins.idas.api.IContextFactory#setPolicy(java.lang.String)
     */
    public void setPolicy(String policy) throws IdASException {
        throw new NotImplementedException();
    }
    
   
    /**
     * 
     * @param mapGlobalSettings
     * @param strComponentName
     * @param mapComponentSettings
     * @throws Exception
     */
    public void configure(
        final Map mapGlobalSettings,
        final String strComponentName,
        final Map mapComponentSettings) throws Exception { 
    	
    	this._apiKey = (String) mapComponentSettings.get("api_key");
    	this._apiSecret = (String) mapComponentSettings.get("api_secret");
    }
}
